import datetime

from flask import Flask, request
# 配置跨域
from flask_cors import CORS
import logging
from logging import FileHandler
# 导入蓝图包
from ceshi import tesxt
# 创建实例
from user_view import views

app = Flask(__name__)
CORS(app)
# 创造蓝图
app.register_blueprint(tesxt)
app.register_blueprint(views)

# 解决中文乱码
app.config['JSON_AS_ASCII'] = False


@app.route('/test')
def hello_world():
    str="请求id:"+request.remote_addr+',请求url'+request.url+"错误信息"
    app.logger.error(str)
    return 'Hello World!'


if __name__ == '__main__':
    filename=datetime.datetime.strftime(datetime.datetime.now(),'%Y%m')
    handler = logging.FileHandler("logs/"+filename+'a.text')
    app.logger.addHandler(handler)
    app.run(debug=True, host='0.0.0.0', port=5000)
